USE DB_TCC
GO
IF EXISTS(SELECT 1 FROM SYSOBJECTS WHERE NAME LIKE 'P_PROCESSO_SELETIVO_LISTAR')
	DROP PROCEDURE P_PROCESSO_SELETIVO_LISTAR
GO
CREATE PROCEDURE P_PROCESSO_SELETIVO_LISTAR(
	@DATADE		DATETIME,
	@DATAATE	DATETIME)
AS BEGIN
	SELECT
		IDPROCESSOSELETIVO,
		NOMEPROCESSOSELETIVO,
		DESCPROCESSOSELETIVO,
		DATAPROVA,
		ATIVO,
		USUARIOINCLUSAO,
		DTHRINCLUSAO,
		USUARIOALTERACAO,
		DTHRALTERACAO
	FROM
		PROCESSO_SELETIVO
	WHERE
		(DATAPROVA >= @DATADE OR CONVERT(DATETIME, @DATADE) IS NULL)
		AND (DATAPROVA <= @DATAATE OR CONVERT(DATETIME, @DATAATE) IS NULL)
		AND ATIVO = 'S'
END